import { IPSAppDEMethod } from '../../app/dataentity/ipsapp-demethod';
import { IPSAppDataEntity } from '../../app/dataentity/ipsapp-data-entity';
import { IPSDEGEIUpdateDetail } from './ipsdegeiupdate-detail';
import { IPSDEGridEditItemUpdate } from './ipsdegrid-edit-item-update';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEGridEditItemUpdateImpl extends PSModelObjectImpl implements IPSDEGridEditItemUpdate {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psappdemethod: IPSAppDEMethod | null = null;

  getPSAppDEMethod(): IPSAppDEMethod | null {
    if (this.psappdemethod != null) return this.psappdemethod;
    const value = this.M.getPSAppDEMethod;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getParentPSModelObject('app.dataentity.IPSAppDataEntity') as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.psappdemethod = ipsappdataentity.findPSAppDEMethod(value);
    }
    return this.psappdemethod;
  }

  get psAppDEMethod(): IPSAppDEMethod | null {
    return this.getPSAppDEMethod();
  }

  getPSAppDEMethodMust(): IPSAppDEMethod {
    const value = this.getPSAppDEMethod();
    if (value == null) {
      throw new Error('未指定处理应用实体方法');
    }
    return value;
  }

  protected psdegeiupdatedetails: IPSDEGEIUpdateDetail[] | null = null;

  getPSDEGEIUpdateDetails(): IPSDEGEIUpdateDetail[] | null {
    if (this.psdegeiupdatedetails == null) {
      this.psdegeiupdatedetails = this.fillChildListModel(this.M.getPSDEGEIUpdateDetails, 'control.grid.IPSDEGEIUpdateDetail') as IPSDEGEIUpdateDetail[];
    }
    return this.psdegeiupdatedetails;
  }

  get psDEGEIUpdateDetails(): IPSDEGEIUpdateDetail[] | null {
    return this.getPSDEGEIUpdateDetails();
  }

  findPSDEGEIUpdateDetail(objKey: any): IPSDEGEIUpdateDetail | null {
    return this.getPSModel5('control.grid.IPSDEGEIUpdateDetail', this.getPSDEGEIUpdateDetails(), objKey) as IPSDEGEIUpdateDetail;
  }

  get scriptCode(): string {
    return this.M.scriptCode;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get customCode(): boolean {
    return this.M.customCode != null ? this.M.customCode : false;
  }

  get showBusyIndicator(): boolean {
    return this.M.showBusyIndicator != null ? this.M.showBusyIndicator : true;
  }

  get cls(): string {
    return 'PSDEGridEditItemUpdateImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.grid.IPSDEGridEditItemUpdate') return true;
    return super.instanceof(cls);
  }
}
